package com.ejlchina.tool

import android.app.Application
import com.ejlchina.tool.network.NetHttpManager
import com.ejlchina.tool.util.BleScan
import com.huyuhui.fastble.BleManager
import com.huyuhui.fastble.common.BleConnectStrategy
import com.kongqw.network.monitor.NetworkMonitorManager
import com.kongzue.dialogx.DialogX

class MyApplication : Application() {

    init {
        instance = this
    }
    override fun onCreate() {
        super.onCreate()
        initBleDevice()
        initNetworkMonitor()
        initNetHttpManager()
        DialogX.init(this);
    }

    private fun initBleDevice(){
        BleManager.apply {
            enableLog(true)
            maxConnectCount = 20
            operateTimeout = 3000
            splitWriteNum = 20
            bleConnectStrategy = BleConnectStrategy.Builder().setConnectOverTime(3000)
                .setConnectBackpressureStrategy(BleConnectStrategy.CONNECT_BACKPRESSURE_DROP)
                .setReConnectCount(0).setReConnectInterval(0).build()
        }.init(this)
    }

    private fun initNetHttpManager(){
        NetHttpManager.getInstance().initCtx(this)
    }

    private fun initNetworkMonitor(){
        NetworkMonitorManager.getInstance().init(this)
    }

    companion object {
        lateinit var instance: MyApplication
    }
}